<?php
/**
 * Created by dailinlin.
 * Date: 2020/3/18 9:51
 * for:
 */


namespace app\traits;


trait Api
{
    /**
     * @param string $msg
     * @param array $data
     * @param integer $code
     * @return array|string
     */
    public static function success($msg = '',$data = [], $code = 200)
    {
        $msg = [
            'status' => true,
            'code'=>$code,
            'message'=>$msg,
            'data'=>$data
        ];
        return $msg;
    }

    /**
     * @param string $msg
     * @param integer $code
     * @return array|string
     */
    public static function error($msg = '', $code = 201,$data = [])
    {
        $msg = [
            'status' => false,
            'code'=>$code,
            'message'=>$msg,
            'data'=>$data
        ];
        return $msg;
    }
}